package springboot_demo.itheima.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import springboot_demo.itheima.pojo.Result;

import java.util.concurrent.atomic.AtomicReference;

/**
 * 功能：
 * 作者：Java课程项目组
 * 日期：2025年04月27日
 */
@RequiredArgsConstructor//有参构造
@RestController
@CrossOrigin//解决跨域问题
@RequestMapping("/ai")
public class ChatBotController {

    private final ChatClient chatClient;

    @GetMapping(value = "/chat", produces = "text/plain;charset=utf-8")
    public Flux<String> chat(String prompt) {
            return chatClient.prompt()
                    .user(prompt)
                    .stream()
                    .content();
    }
}
